﻿#include "widget.h"
#include "ui_widget.h"
#include "time.h"
#include <QPushButton>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    this->resize(500,500);

    btn = new QPushButton("爬",this);
    connect(btn,&QPushButton::clicked,this,&Widget::moveButton);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::moveButton()
{
    static int i = 0;
    srand(i);
    int num = rand();
    i += num;
    btn->move(i%500,i%500);
}

void Widget::on_btn2_clicked()
{
    static int i = 0;
    srand(i);
    int num = rand();
    i += num;
    ui->btn2->move(i%500,i%500);
}
